#include <iostream>

class A
{
public:
    virtual void foo(void) {
        std::cout << "A foo" << std::endl;
    }
    void pp(void) {
        std::cout << "A pp" << std::endl;
    }
};

class B : public A
{
public:
    void foo(void) {
        std::cout << "B foo" << std::endl;
    }
    void pp(void) {
        std::cout << "B pp" << std::endl;
    }
    void FunctionB(void) {
        std::cout << "Excute FunctionB!" << std::endl;
    }
};

int main(int argc, const char *argv[])
{
    A a;
    A *pa = &a;
    pa->foo();
    pa->pp();

    (dynamic_cast<B *>(pa))->FunctionB();
    (dynamic_cast<B *>(pa))->pp();
    (dynamic_cast<B *>(pa))->foo();
    return 0;
}
